<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="ja" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta http-equiv="Content-Style-Type" content="text/css">
<!-- meta -->
<meta name="keywords" content="">
<meta name="description" content="">
<!-- /meta -->
<title>入力形式 作成</title>
<!-- JQuery 用 -->
<link href="<%= request.getContextPath() %>/common/css/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="<%= request.getContextPath() %>/common/js/jquery-1.4.4.min.js" type="text/javascript"></script>
<script src="<%= request.getContextPath() %>/common/js/jquery-ui-1.8.9.custom.min.js" type="text/javascript"></script>
<script src="<%= request.getContextPath() %>/common/js/jquery.cookie.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/base.css">
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/headerfooter.css">
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/ulol.css">
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/arrow.css">
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/elements.css">
<!-- admin -->
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/base_admin.css">
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/elements_admin.css">
<!-- /admin -->
<script type="text/javascript" src="<%= request.getContextPath() %>/common/js/library.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/for_winie3.css">
<!--[if gte IE 5]>
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/for_over_winie5.css">
<![endif]-->
<!--[if IE 5]>
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/for_winie5.css">
<![endif]-->

<script language="JavaScript">

<s:if test=' successSign != null '>
	<s:if test=' successSign == "1" '>
		alert("リスト内容を入力してください。");
	</s:if>
	<s:else>
		if (!window.opener) {
			alert("親Windowがないです。");
			window.close();
		} else {
			window.opener.editInputType('${editIndex}', '${type}', '${optionKbn}','<s:property value="optionResult" escape="false" escapeJavaScript="true"/>');
			window.close();
		}

	</s:else>
</s:if>

	jQuery.event.add(window, "load", init);


	function init() {

		$('#defaultKbnid').click(checkChangeEvent);
	}

	var checkChangeEvent = function(event) {

		var target = $(event.target);

		if (target.attr('checked') == true){
			$('#options0').attr('disabled','');
			target.parent().next().children(':first').focus();
		} else {
			$('#options0').attr('value','');
			$('#options0').attr('disabled','disabled');
		}

	};


	function selectField(fieldkey){

		$('#selectFieldName').val(fieldkey);
		$('#selectField').val(fieldkey);

		document.frm.action = '<%= request.getContextPath() %>/outputschema/popupCreateInputItem-selectField';
		document.frm.submit();
	}


	//作成ボタンを押下した場合,親画面に入力形式を設定する
	function makeInputType(){

		document.frm.action = '<%= request.getContextPath() %>/outputschema/popupCreateInputItem-make';
		document.frm.submit();
	}

	function doDeleteRow(index) {
		document.getElementById("deleteId").value = index;
		document.frm.action = '<%= request.getContextPath() %>/outputschema/popupCreateInputItem-deleteRow';
		document.frm.submit();
	}

	function doInsertRow() {
		document.frm.action = '<%= request.getContextPath() %>/outputschema/popupCreateInputItem-add';
		document.frm.submit();
	}

	function doSelectBoxChange() {
		document.frm.action = '<%= request.getContextPath() %>/outputschema/popupCreateInputItem-change';
		document.frm.submit();
	}

	function doSelectField() {

		var url = '<%= request.getContextPath() %>/outputschema/popupFieldselect';
		window.open(url,'child3', 'width=650, height=600, menubar=no, toolbar=no, scrollbars=yes');


	}


</script>
</head>
<body id="dch" >
<!-- === headerArea === -->
<div id="headerArea">
<a name="pageTop" id="pageTop"></a>
</div><!-- === /headerArea === -->
<!-- === mainArea === -->
<div id="mainArea">
<form name="frm" action="<%= request.getContextPath() %>/outputschema/popupCreateInputItem" >
<s:hidden name = "editIndex" />
<s:hidden name = "optionResult" />

<s:hidden name = "selectField" />
<input type="hidden" id = "deleteId" name = "deleteIndex" />
<table border="0" cellspacing="0" cellpadding="0" width="100%">
	<tr valign="top">
		<td width="20"><img src="<%= request.getContextPath() %>/common/images/spacer.gif" width="20" height="4" border="0" alt=""></td>
		<td id="contentsArea">
		<!-- === contentsArea === -->
			<!-- headingLv01Block -->
			<div class="headingLv01Block">
				<!-- headingLv01 -->
				<h1>入力形式 作成</h1>
				<!-- /headingLv01 -->
				<!-- lead -->
				<div class="lead">
				</div>
				<!-- /lead -->
			</div>
			<!-- /headingLv01Block -->
			<!-- columnB01 -->
			<div class="columnB01">
				<p class="text">入力形式の作成を行います</p>
			</div>
			<!-- /columnB01 -->

			<div class="tableBlock">
				<!-- tableA01 -->
				<div class="tableA01">
				<table border="1" cellspacing="0" cellpadding="5" width="558">
					<tr>
						<!-- ラベル -->
						<th class="lv01B" width="170" colspan="2"><label for="fServiceName">形式</label></th>
						<!-- エラー --><th width="11" class="error">&nbsp;</th>
						<!-- 内容 -->
						<td>
							<s:select list="#{'0':'テキストボックス','6':'複数テキスト','1':'テキストエリア','2':'ドロップダウンリスト',
								'3':'ラジオボタン','4':'チェックボックス','5':'日付','7':'フィールド指定'}" name="type" onchange="doSelectBoxChange()"/>

							<c:if test="${type == '0'}" >
								<c:if test="${optionKbn == 'on'}" >
									<input type="checkbox" name="optionKbn" id = "defaultKbnid" checked="checked" /><label for="defaultKbnid" >デフォルト設定</label>
								</c:if>
								<c:if test="${optionKbn == 'off' || optionKbn == '' || optionKbn == null}" >
									<input type="checkbox" name="optionKbn" id = "defaultKbnid" /><label for="defaultKbnid" >デフォルト設定</label>
								</c:if>
							</c:if>

							<c:if test="${type == '2'}" >
								<c:if test="${optionKbn == 'on'}" >
									<input type="checkbox" name="optionKbn" id = "optionKbnid" checked="checked" /><label for="optionKbnid" >複数選択可</label>
								</c:if>
								<c:if test="${optionKbn == 'off' || optionKbn == '' || optionKbn == null}" >
									<input type="checkbox" name="optionKbn" id = "optionKbnid" /><label for="optionKbnid" >複数選択可</label>
								</c:if>
							</c:if>
							<c:if test="${type == '3' || type == '4'}" >
								<c:if test="${optionKbn == 'on'}" >
									<input type="checkbox" name="optionKbn" id = "optionKbnid" checked="checked" /><label for="optionKbnid" >フリーワード可</label>
								</c:if>
								<c:if test="${optionKbn == 'off' || optionKbn == '' || optionKbn == null}" >
									<input type="checkbox" name="optionKbn" id = "optionKbnid" /><label for="optionKbnid" >フリーワード可</label>
								</c:if>
							</c:if>
						</td>
					</tr>
					<tr>
						<!-- ラベル -->
						<th class="lv01B" width="170" colspan="2"><label for="fServiceName">リスト</label></th>
						<!-- エラー -->
						<th width="11" class="error">&nbsp;</th>
						<!-- 内容 -->
							<td width="300">
								<s:if test=' type == "0" '>
									<table id="innsertbl" border="1"  cellspacing="0" cellpadding="5" width="300">
										<tr>
											<td>
												<c:if test="${optionKbn == 'on'}" >
													<s:textfield id= "options0" name= "options[0]" size="30"/>
												</c:if>
												<c:if test="${optionKbn == 'off' || optionKbn == '' || optionKbn == null}" >
													<s:textfield id= "options0" name= "options[0]" size="30" disabled="true" />
												</c:if>
											</td>
										</tr>
									</table>
								</s:if>

								<s:elseif test=' type == "2" or type == "3" or type == "4" ' >
									<div class="tableA01" id="optionDiv" >
										<table id="innsertbl" border="1"  cellspacing="0" cellpadding="5" width="300">
											<tr>
												<th class="lv01B" width="10">&nbsp;操作</th>
												<th class="lv01B">名称</th>
											</tr>
											<s:iterator value="options" status="sta">
											<tr>
												<td>
													<input type="button" value="削除" onClick="doDeleteRow(${sta.index})">
												</td>
												<td>
													<s:textfield name= "options[%{#sta.index}]" size="30"/>
												</td>
											</tr>
											</s:iterator>
										</table>
										<input type="button" value="追加する" onclick="doInsertRow();">
									</div>
								</s:elseif>
								<s:elseif test=' type == "7" '>
									<table id="innsertbl" border="1"  cellspacing="0" cellpadding="5" width="300">
											<tr>
												<th class="lv01B">名称</th>
											</tr>
											<tr>
												<td>
													<s:property value="selectFieldName" />
													<s:hidden name= "options[0]"/>
												</td>
											</tr>
										</table>
									<input type="button" value="選択する" onclick="doSelectField();">
								</s:elseif>
							</td>
					</tr>
				</table>
				</div>
				<!-- /tableA01 -->
			</div>
			<!-- pageNaviC01 -->
			<div class="pageNaviC01">
			<table border="0" cellspacing="0" cellpadding="10" width="558">
				<tr>
					<td width="298" class="left"><p><input type="button" value="キャンセル" style="width:100px" onclick="window.close();"></p></td>
					<td width="130" class="left">&nbsp;</td>
					<td width="130" class="right"><p><input type="button" value="作成する" style="width:130px" onclick="makeInputType()"></p></td>
				</tr>
			</table>
			</div>
			<div style="display:none">
				<span id="inputOptionSpan"></span>
			</div>
			<!-- /pageNaviC01 -->
			<!-- === /contentsArea === -->
		</td>
		<td width="16"><img src="<%= request.getContextPath() %>/common/images/spacer.gif" width="16" height="4" border="0" alt=""></td>
	</tr>
</table>
</form>
</div><!-- === /mainArea === -->
<!-- === footerArea === -->
<div id="footerArea">
<!--#include virtual="<%= request.getContextPath() %>/common/include/footer.html" -->
</div><!-- === /footerArea === -->
</body>
</html>
<!-- System Architect is COOBA Corp
	Copyright 2010 COOBA Corp All rights reserved -->